#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

string s;
int n, totalB, countB, minB;

int main()
{
	while (true)
	{
		scanf("%d\n", &n);
		if (n == 0) break;

		totalB = 0;
		minB = 100;
		for (int i = 0; i < n; i++)
		{
			countB = 0;
			getline(cin, s);

			for (int i = 0; i < s.size(); i++)
				if (s[i] == ' ') countB++;

			if (minB > countB) minB = countB;
			totalB += countB;
		}

		cout << totalB - (minB*n) << endl;
	}
	return 0;
}
